<include file="public@header"/>
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('School/index')}">所有学校</a></li>
			<li class="active"><a>编辑学校</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('School/edit')}">
			<div class="form-group">
				<label class="col-sm-2 control-label">所属省区<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10" >
					<select class="form-control" name="province" id="input-province" >
						<foreach name="province" item="vo">
							<if $school.province == $vo.areaId or $school.province == $vo.areaName>
							<option value="{$vo.areaId}" selected>{$vo.areaName}</option>
								<else />
									<option value="{$vo.areaId}">{$vo.areaName}</option>
							</if>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">所属城市<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10" >
					<select class="form-control" id="input-city" name="city" lay-filter="selectSchool">
						<foreach name="city" item="vo">
							<if $school.city == $vo.areaId or $school.city == $vo.areaName>
								<option value="{$vo.areaId}" selected>{$vo.areaName}</option>
								<else>
									<option value="{$vo.areaId}">{$vo.areaName}</option>
							</else>
						</if>
					</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">所属县区<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10" >
					<select class="form-control" id="input-area" name="area" lay-filter="selectSchool">
						<foreach name="area" item="vo">
						<if $school.area == $vo.areaId or $school.area == $vo.areaName>
							<option value="{$vo.areaId}" selected>{$vo.areaName}</option>
							<else>
								<option value="{$vo.areaId}">{$vo.areaName}</option>
							</else>
						</if>
						</foreach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="name" class="col-sm-2 control-label">学校名称<span class="form-required">*</span></label>
				<div class="col-md-6 col-sm-10">
					<input type="text" class="form-control" id="name" name="name" value="{$school.name}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>详细地址</label>
				<div class="col-md-6 col-sm-10">
					<input type="text" id="address" name="address" class="layui-input" value="{$school.address}">
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="id" value="{$school.id}">
					<button type="submit" class="btn btn-primary js-ajax-submit">{:lang('SAVE')}</button>
					<a class="btn btn-default" href="{:url('school/index')}">{:lang('BACK')}</a>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
</body>
<script>
    $(function () {
        $('#input-province').change('change',function () {
            var areaId=$(this).val();
            //alert(schoolId);
            $.ajax({
                url:"{:url('school/getCity')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    $('#input-city').html(res);
                    console.log(res);
                }
            })
        })
    })
</script>
<script>
    $(function () {
        $('#input-city').change('change',function () {
            var cityId=$(this).val();
            $.ajax({
                url:"{:url('school/getArea')}",
                type:"POST",
                data:{cityId:cityId},
                success:function (res) {
                    $('#input-area').html(res);
                    console.log(res);
                }
            })
        })
    })
</script>
</html>